;;;; Rogue Skirmish copyright 2010 Adam White (theroguemonkey@gmail.com)
;;;; Licensed under GNU General Public Licence v2 or later - refer COPYING


(in-package #:skirmish)

(defclass mini (creature)
  ((faction
    :initarg :faction
    :accessor faction
    :initform nil)
   (powers
    :initarg :powers
    :accessor powers
    :initform nil)
   (health
    :initarg :health
    :accessor health)
   (mana
    :initarg :mana
    :accessor mana)))


(defmethod initialize-instance :after ((mini mini) &key map coords)
  (let* ((size  (1- (@size mini)))
	 (pos (collect-coords-square coords size)))
    (dolist (p pos) (setf (creature-at p map) mini))))



(defun move (mini map pos)
  (let* ((size (1- (@size mini)))
	 (curpos (collect-coords-square (@coords mini)  size))
	 (newpos (collect-coords-square pos size)))
    (if (passable-p pos mini map)
	(progn
	  (format t "Yeah baby. Moved to ~A/~A~%" (car pos) (cdr pos))
	  (dolist (p curpos) (setf (creature-at p map) nil))
	  (dolist (p newpos) (setf (creature-at p map) mini))
	  (setf (@coords mini) pos
		(@map mini) map)
	  1)
	0)))


(defun move* (mini adj)
  (move mini (@map mini) (apply #'adj-coords (@coords mini) adj)))
